<template>
  <div>
    <Echart :options="options" id="callChart" height="180px" width="100%"></Echart>
  </div>
</template>

<script>
import Echart from '@/common/echart'
export default {
  data () {
    return {
      options: {},
    };
  },
  components: {
    Echart,
  },
  props: {
    cdata: {
      type: Object,
      default: () => ({})
    },
  },
  watch: {
    cdata: {
      handler (newData) {
        this.options = {
          color: [
            "#37a2da",
            "#ffdb5c",
            "#32c5e9",
            "#9fe6b8",
            "#ff9f7f",
            "#fb7293",
            "#e7bcf3",
            "#8378ea"
          ],
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b} : {c} ({d}%)"
          },
          toolbox: {
            show: true
          },
          calculable: true,
          legend: {
            show: false,
            orient: "horizontal",
            icon: "circle",
            bottom: 0,
            x: "center",
            data: newData.xData,
            textStyle: {
              color: "#fff"
            }
          },
          series: [
            {
              name: "要车量",
              type: "pie",
              radius: [10, 50],
              roseType: "area",
              center: ["50%", "50%"],
              data: newData.seriesData,
              // 新增：配置标签（引出线对应的文字）
              label: {
                show: true,
                // 格式化标签内容：{b}是名称，{c}是数据值，{d}是百分比
                formatter: '{b}: {c}'
              },
              // 配置标签连接线（确保线可见）
              labelLine: {
                show: true
              }
            }
          ]
        }
      },
      immediate: true,
      deep: true
    }
  }
};
</script>

<style lang="scss" scoped>
</style>
